package com.yequan.tryfinally;

/**
 * @author yq
 * @date 2020/09/15
 */
public class TryTest {

    public static void main(String[] args) throws Exception {
//        doTestTry();

        doTestTryFinally();
    }

    public static void doTestTryFinally() throws Exception {
        int a = 3;
        try {
            if (a == 3) {
                throw new Exception("ddddd");
            }
            System.out.println("jjjjj");
        } finally {
            System.out.println("hhhhh");
        }
    }

    public static void doTestTry() {
        int i = testTry();
        System.out.println(i);
    }

    public static int testTry() {
        try {
            for (int i = 0; i < 10; i++) {
                if (i == 6) {
                    return i;
                }
            }
        } finally {
            System.out.println("执行了finally");
        }
        return -1;
    }

}
